﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Management.Automation;

namespace BO.Management.PowerShell
{
    /// <summary>
    /// Base Cmdlet to write in the pipeline a BO object or a list of BO Objects according parameters used for searching
    /// </summary>
    public abstract class BaseGetObject<T,U> : BaseBOEObject<T,U> where T : BaseObjectProvider<U> 
                                                             where U: CrystalDecisions.Enterprise.InfoObject
    {

        /// <summary>
        /// Write in the pipeline the object which has been found with parameters
        /// </summary>
        /// <param name="boeObject"></param>
        public override void WorkWithSingleObject(U boeObject)
        {
            this.WriteObject(boeObject);
        }

        /// <summary>
        /// Write in the pipeline the list of objects which has been found with parameters
        /// </summary>
        /// <param name="boeObject"></param>
        public override void WorkWithListObjects(List<U> boeObjects)
        {
            foreach (U boeObject in boeObjects)
            {
                this.WorkWithSingleObject(boeObject);
            }
            //this.WriteObject(boeObjects);
        }
    }
}
